import request from '@/utils/request'

/** -------------------停车月卡相关请求函数-------------------- */
/**
 * 获取车辆列表
 *
 * @param { page, pageSize, carNumber, personName, cardStatus } params
 *
 * @returns {Promise}
 */
export function getCarListAPI(params) {
  return request({
    url: '/parking/card/list',
    method: 'get',
    params
  })
}

/**
 * 添加月卡
 *
 * @param { personName, phoneNumber, carNumber, carBrand, cardStartDate, cardEndDate, paymentAmount, paymentMethod } data
 *
 * @returns {Promise}
 */
export function addCardAPI(data) {
  return request({
    url: '/parking/card',
    method: 'post',
    data
  })
}

/**
 * 查看编辑页月卡详情
 *
 * @param { String } id
 *
 * @returns {Promise}
 */
export function getCardDetailAPI(id) {
  return request({
    url: `/parking/card/detail/${id}`,
    method: 'get'
  })
}

/**
 * 编辑月卡
 *
 * @param { personName, phoneNumber, carNumber, carBrand, cardStartDate, cardEndDate, paymentAmount, paymentMethod, carInfoId, rechargeId } data
 *
 * @returns {Promise}
 */
export function editCardAPI(data) {
  return request({
    url: '/parking/card/edit',
    method: 'put',
    data
  })
}

/**
 * 删除月卡
 *
 * @param { String } id
 *
 * @returns {Promise}
 */
export function deleteCardAPI(id) {
  return request({
    url: `/parking/card/${id}`,
    method: 'delete'
  })
}

/**
 * 批量删除月卡
 *
 * @param { String } ids id用逗号隔开
 *
 * @returns {Promise}
 */
export function deleteCardListAPI(ids) {
  return request({
    url: `/parking/card/${ids}`,
    method: 'delete'
  })
}

/**
 * 月卡续费
 *
 * @param { cardStartDate, cardEndDate, paymentAmount, paymentMethod, carInfoId } data
 *
 * @returns {Promise}
 */
export function renewCardAPI(data) {
  return request({
    url: '/parking/card/recharge',
    method: 'post',
    data
  })
}

/**
 * 查看月卡详情
 *
 * @param { String } id
 *
 * @returns {Promise}
 */
export function getCardInfoAPI(id) {
  return request({
    url: `/parking/card/${id}`,
    method: 'get'
  })
}
